home *** CD-ROM | disk | FTP | other *** search
/ La Bible Des... Jeux / La Bible des... Jeux.iso / Les Sharewares / Educatifs / A Panda is for Life... / Musical Panda / Musical Panda.6 / 00120_Snowflake.ls < prev    next >
Encoding:
Text File  |  1995-12-03  |  4.1 KB  |  148 lines

  1. property deltaV, deltaH, deltaZ, mysprite, myCast, myFrame, myScale, theCharmed, theWidth, theHeight
  2.  
  3. on birth me, listposition, startChannel
  4.   set mylistposition to listposition
  5.   set mysprite to mylistposition + startChannel
  6.   set myFrame to 0
  7.   set deltaV to random(9) - 5
  8.   set deltaH to random(9) - 5
  9.   set deltaZ to random(3) - 2
  10.   if deltaZ <> 0 then
  11.     set myScale to random(3) + 1
  12.   else
  13.     set myScale to 1
  14.   end if
  15.   set theHeight to the height of cast "A1"
  16.   set theWidth to the width of cast "A1"
  17.   set myCast to the number of cast "A1" + ((random(6) - 1) * 7) + 1
  18.   set the castNum of sprite mysprite to myCast
  19.   set myFrame to myCast
  20.   set the locV of sprite mysprite to random(344) + 40
  21.   set the locH of sprite mysprite to random(260) + 40
  22.   set the height of sprite mysprite to theHeight / myScale
  23.   set the width of sprite mysprite to theWidth / myScale
  24.   return me
  25. end
  26.  
  27. on animateFlake me
  28.   set myFrame to myFrame + 1
  29.   if myFrame = (myCast + 6) then
  30.     set myFrame to myCast
  31.   end if
  32.   set the castNum of sprite mysprite to myFrame
  33.   if theCharmed = 1 then
  34.     if (the mouseH < the locH of sprite mysprite) and (deltaH > -4) then
  35.       set deltaH to deltaH - 1
  36.     else
  37.       if (the mouseH > the locH of sprite mysprite) and (deltaH < 4) then
  38.         set deltaH to deltaH + 1
  39.       end if
  40.     end if
  41.     if (the mouseV < the locV of sprite mysprite) and (deltaV > -4) then
  42.       set deltaV to deltaV - 1
  43.     else
  44.       if (the mouseV > the locV of sprite mysprite) and (deltaV < 4) then
  45.         set deltaV to deltaV + 1
  46.       end if
  47.     end if
  48.     if (abs(the mouseH - the locH of sprite mysprite) < 20) and (abs(the mouseV - the locV of sprite mysprite) < 20) then
  49.       puppetSound("CharmOff")
  50.       set theCharmed to 0
  51.       set deltaV to -deltaV
  52.       set deltaH to -deltaH
  53.     end if
  54.   end if
  55.   if theCharmed = 0 then
  56.     if random(250) = 1 then
  57.       set deltaV to random(9) - 5
  58.     end if
  59.     if random(250) = 1 then
  60.       set deltaH to random(9) - 5
  61.     end if
  62.   end if
  63.   set currentVPOS to the locV of sprite mysprite + deltaV
  64.   set currentHPOS to the locH of sprite mysprite + deltaH
  65.   if currentVPOS < 50 then
  66.     set currentVPOS to 50
  67.     set deltaV to 5
  68.   end if
  69.   if currentHPOS < 50 then
  70.     set currentHPOS to 50
  71.     set deltaH to 5
  72.   end if
  73.   if (currentVPOS > 200) and (currentHPOS > 300) then
  74.     set currentVPOS to 200
  75.     set deltaV to -5
  76.   else
  77.     if currentVPOS > 400 then
  78.       set currentVPOS to 400
  79.       set deltaV to -5
  80.     end if
  81.   end if
  82.   if (currentHPOS > 300) and (currentVPOS > 200) then
  83.     set currentHPOS to 300
  84.     set deltaH to -5
  85.   else
  86.     if currentHPOS > 400 then
  87.       set currentHPOS to 400
  88.       set deltaH to -5
  89.     end if
  90.   end if
  91.   set the locV of sprite mysprite to currentVPOS
  92.   set the locH of sprite mysprite to currentHPOS
  93.   if deltaZ = -1 then
  94.     if myScale = 4 then
  95.       set deltaZ to random(2) - 1
  96.     else
  97.       set myScale to myScale + 1
  98.       set the height of sprite mysprite to theHeight / myScale
  99.       set the width of sprite mysprite to theWidth / myScale
  100.     end if
  101.   else
  102.     if deltaZ = 1 then
  103.       if myScale = 1 then
  104.         set deltaZ to random(2) - 2
  105.       else
  106.         set myScale to myScale - 1
  107.         set the height of sprite mysprite to theHeight / myScale
  108.         set the width of sprite mysprite to theWidth / myScale
  109.       end if
  110.     else
  111.       set deltaZ to random(3) - 2
  112.     end if
  113.   end if
  114. end
  115.  
  116. on swapFlake me
  117.   set currentVPOS to the locV of sprite mysprite
  118.   set currentHPOS to the locH of sprite mysprite
  119.   set myCast to the number of cast "A1" + ((random(6) - 1) * 7) + 1
  120.   set the castNum of sprite mysprite to myCast
  121.   set myFrame to myCast
  122.   set the locV of sprite mysprite to currentVPOS
  123.   set the locH of sprite mysprite to currentHPOS
  124. end
  125.  
  126. on dragFlake me
  127.   set currentVPOS to the mouseV
  128.   set currentHPOS to the mouseH
  129.   set the locV of sprite mysprite to currentVPOS
  130.   set the locH of sprite mysprite to currentHPOS
  131.   swapFlake(me)
  132.   updateStage()
  133. end
  134.  
  135. on charmFlake me
  136.   set theCharmed to 1
  137. end
  138.  
  139. on toggleCharm me
  140.   if theCharmed = 1 then
  141.     puppetSound("CharmOff")
  142.     set theCharmed to 0
  143.   else
  144.     puppetSound("CharmOn")
  145.     set theCharmed to 1
  146.   end if
  147. end
  148.